/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package co.com.entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author 839398
 */
@Entity
@Table(name = "tbl_usuario")
@NamedQueries({
    @NamedQuery(name = "TblUsuario.findAll", query = "SELECT t FROM TblUsuario t"),
    @NamedQuery(name = "TblUsuario.findByUsuario", query = "SELECT t FROM TblUsuario t WHERE t.tblUsuarioPK.usuario = :usuario"),
    @NamedQuery(name = "TblUsuario.findByNatillera", query = "SELECT t FROM TblUsuario t WHERE t.tblUsuarioPK.natillera = :natillera"),
    @NamedQuery(name = "TblUsuario.findByClave", query = "SELECT t FROM TblUsuario t WHERE t.clave = :clave"),
    @NamedQuery(name = "TblUsuario.findByCorreo", query = "SELECT t FROM TblUsuario t WHERE t.correo = :correo")})
public class TblUsuario implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TblUsuarioPK tblUsuarioPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "clave")
    private String clave;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 35)
    @Column(name = "correo")
    private String correo;
    @JoinColumns({
        @JoinColumn(name = "usuario", referencedColumnName = "doc_persona", insertable = false, updatable = false),
        @JoinColumn(name = "natillera", referencedColumnName = "cod_natillera", insertable = false, updatable = false)})
    @OneToOne(optional = false)
    private TblNatilleraPersona tblNatilleraPersona;

    public TblUsuario() {
    }

    public TblUsuario(TblUsuarioPK tblUsuarioPK) {
        this.tblUsuarioPK = tblUsuarioPK;
    }

    public TblUsuario(TblUsuarioPK tblUsuarioPK, String clave, String correo) {
        this.tblUsuarioPK = tblUsuarioPK;
        this.clave = clave;
        this.correo = correo;
    }

    public TblUsuario(String usuario, int natillera) {
        this.tblUsuarioPK = new TblUsuarioPK(usuario, natillera);
    }

    public TblUsuarioPK getTblUsuarioPK() {
        return tblUsuarioPK;
    }

    public void setTblUsuarioPK(TblUsuarioPK tblUsuarioPK) {
        this.tblUsuarioPK = tblUsuarioPK;
    }

    public String getClave() {
        return clave;
    }

    public void setClave(String clave) {
        this.clave = clave;
    }

    public String getCorreo() {
        return correo;
    }

    public void setCorreo(String correo) {
        this.correo = correo;
    }

    public TblNatilleraPersona getTblNatilleraPersona() {
        return tblNatilleraPersona;
    }

    public void setTblNatilleraPersona(TblNatilleraPersona tblNatilleraPersona) {
        this.tblNatilleraPersona = tblNatilleraPersona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tblUsuarioPK != null ? tblUsuarioPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblUsuario)) {
            return false;
        }
        TblUsuario other = (TblUsuario) object;
        if ((this.tblUsuarioPK == null && other.tblUsuarioPK != null) || (this.tblUsuarioPK != null && !this.tblUsuarioPK.equals(other.tblUsuarioPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + tblUsuarioPK;
    }
    
}
